package com.devmindset.legoframework.client.mvc.binding;

import java.util.Collection;
import java.util.Map;

/**
 * Base model interface.
 */
public interface Model {

  /**
   * Returns the named property from this model instance.
   * 
   * @param property the property name
   * @param <X> the type
   * 
   * @return the value
   */
  <X> X get(String property);

  /**
   * Returns the model's properties and values as a map.
   * 
   * <p/>Changes to the returned collection should not mutate this model
   * instance.
   * 
   * @return the properties and values
   */
  Map<String, Object> getProperties();

  /**
   * Returns an collection of the model's property names.
   * 
   * <p/>The collection should be a snapshot of the property names that the
   * model represents.
   * 
   * <p/>Changes to the returned collection should not mutate this model
   * instance.
   * 
   * @return the collection
   */
  Collection<String> getPropertyNames();

  /**
   * Removes the named property from this model instance.
   * 
   * @param property the property name
   * @param <X> the type
   * 
   * @return the old value for the property
   */
  <X> X remove(String property);

  /**
   * Sets a property.
   * 
   * @param property the property name
   * @param value property value
   * @param <X> the type
   * 
   * @return the old value for the property
   */
  <X> X set(String property, X value);

}